package com.mialab.servlet_demo;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/ResponseHeadServlet")
public class ResponseHeadServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public ResponseHeadServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 5秒后刷新并跳转到苏州大学网站首页
		response.setHeader("Refresh", "5;URL=http://www.suda.edu.cn");
		// 每隔2秒定时刷新当前页面
		// response.setHeader("Refresh", "2");
		response.getWriter().println(new java.util.Date());// 输出当前时间
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
